/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.stefanini.informacion_mundialista_data;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author gbuitrago
 */
@Entity
@Table(name = "LLAVE")
@NamedQueries({
    @NamedQuery(name = "Llave.findAll", query = "SELECT l FROM Llave l"),
    @NamedQuery(name = "Llave.findById", query = "SELECT l FROM Llave l WHERE l.id = :id"),
    @NamedQuery(name = "Llave.findByRonda", query = "SELECT l FROM Llave l WHERE l.ronda = :ronda"),
    @NamedQuery(name = "Llave.findByPosicionGrupo1", query = "SELECT l FROM Llave l WHERE l.posicionGrupo1 = :posicionGrupo1"),
    @NamedQuery(name = "Llave.findByPosicionGrupo2", query = "SELECT l FROM Llave l WHERE l.posicionGrupo2 = :posicionGrupo2")})
public class Llave implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SecuenciaLlave")
    @SequenceGenerator(sequenceName = "LLAVE_ID_SEQ", name = "SecuenciaLlave")
    private Long id;
    
    @Basic(optional = false)
    @Column(name = "RONDA")
    private String ronda;
    @Column(name = "POSICION_GRUPO_1")
    private Short posicionGrupo1;
    @Column(name = "POSICION_GRUPO_2")
    private BigInteger posicionGrupo2;
    @OneToMany(mappedBy = "llaveId")
    private Collection<Partido> partidoCollection;
    @OneToMany(mappedBy = "llave1Id")
    private Collection<Llave> llaveCollection;
    @JoinColumn(name = "LLAVE_1_ID", referencedColumnName = "ID")
    @ManyToOne
    private Llave llave1Id;
    @OneToMany(mappedBy = "llave2Id")
    private Collection<Llave> llaveCollection1;
    @JoinColumn(name = "LLAVE_2_ID", referencedColumnName = "ID")
    @ManyToOne
    private Llave llave2Id;
    @JoinColumn(name = "GRUPO_1_ID", referencedColumnName = "ID")
    @ManyToOne
    private Grupo grupo1Id;
    @JoinColumn(name = "GRUPO_2_ID", referencedColumnName = "ID")
    @ManyToOne
    private Grupo grupo2Id;

    public Llave() {
    }

    public Llave(Long id) {
        this.id = id;
    }

    public Llave(Long id, String ronda) {
        this.id = id;
        this.ronda = ronda;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getRonda() {
        return ronda;
    }

    public void setRonda(String ronda) {
        this.ronda = ronda;
    }

    public Short getPosicionGrupo1() {
        return posicionGrupo1;
    }

    public void setPosicionGrupo1(Short posicionGrupo1) {
        this.posicionGrupo1 = posicionGrupo1;
    }

    public BigInteger getPosicionGrupo2() {
        return posicionGrupo2;
    }

    public void setPosicionGrupo2(BigInteger posicionGrupo2) {
        this.posicionGrupo2 = posicionGrupo2;
    }

    public Collection<Partido> getPartidoCollection() {
        return partidoCollection;
    }

    public void setPartidoCollection(Collection<Partido> partidoCollection) {
        this.partidoCollection = partidoCollection;
    }

    public Collection<Llave> getLlaveCollection() {
        return llaveCollection;
    }

    public void setLlaveCollection(Collection<Llave> llaveCollection) {
        this.llaveCollection = llaveCollection;
    }

    public Llave getLlave1Id() {
        return llave1Id;
    }

    public void setLlave1Id(Llave llave1Id) {
        this.llave1Id = llave1Id;
    }

    public Collection<Llave> getLlaveCollection1() {
        return llaveCollection1;
    }

    public void setLlaveCollection1(Collection<Llave> llaveCollection1) {
        this.llaveCollection1 = llaveCollection1;
    }

    public Llave getLlave2Id() {
        return llave2Id;
    }

    public void setLlave2Id(Llave llave2Id) {
        this.llave2Id = llave2Id;
    }

    public Grupo getGrupo1Id() {
        return grupo1Id;
    }

    public void setGrupo1Id(Grupo grupo1Id) {
        this.grupo1Id = grupo1Id;
    }

    public Grupo getGrupo2Id() {
        return grupo2Id;
    }

    public void setGrupo2Id(Grupo grupo2Id) {
        this.grupo2Id = grupo2Id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Llave)) {
            return false;
        }
        Llave other = (Llave) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.stefanini.informacion_mundialista_data.Llave[ id=" + id + " ]";
    }
    
}
